package io.github.loan.common.util;

import java.util.Random;

import org.springframework.stereotype.Component;

/**
 * 正则表达式的工具类
 * @author Andone
 *
 */
@Component("regexUtil")
public class RegexUtil {
	
	public String randStr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	
	/**
	 * 生成随机字符串
	 */
	public String randString(int length){
		StringBuffer sb=new StringBuffer();
		Random random=new Random();
		for(int i=0;i<length;i++){
			int randIndex=random.nextInt(this.randStr.length());
			sb.append(randStr.charAt(randIndex));
		}
		return sb.toString();
	}
	
	public static void main(String[] args) {
		RegexUtil regexUtil=new RegexUtil();
		System.out.println(regexUtil.randString(32));
	}
}
